<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>      
    <div id="app">
        <div v-if='seen'>
            <div v-pin>
                {{message}}
            </div>
        </div>
    </div>
</body>
<script src="https://cn.vuejs.org/js/vue.js"></script>
<script>
Vue.directive("pin",{
    bind:function(el){
        el.style.position = 'fixed';
        el.style.top = 0 + 'px';
        el.style.width = '100%';
        el.style.height = '200px';
        el.style.lineHeight = "200px";
        el.style.background = 'red';
        el.style.textAlign = 'center';
    },
})
let vm = new Vue({
    el:"#app",
    data:{
        seen:true,
        foo:"fool",
        message:"message"
    }
});

</script>
</html>